/**
 * 
 */
package belote.util.logging;

import java.util.logging.Level;

import org.apache.commons.lang.StringUtils;

/**
 * @author Gwenn
 * 
 */
public class Logger {

	// ------------------------------------------------------------------------
	// ATTRIBUTS
	// ------------------------------------------------------------------------

	private final java.util.logging.Logger LOGGER;

	// ------------------------------------------------------------------------
	// CONSTRUCTEUR
	// ------------------------------------------------------------------------

	/**
	 * Constructeur.
	 */
	protected Logger(String pName) {

		LOGGER = java.util.logging.Logger.getLogger(pName);
	}

	// ------------------------------------------------------------------------
	// METHODES 'PUBLIC'
	// ------------------------------------------------------------------------

	public boolean isDebugEnabled() {

		return LOGGER.isLoggable(Level.FINE);
	}

	public void debug(String pMessage) {

		LOGGER.log(Level.FINE, pMessage);
	}

	public void debug(Throwable pThrowable) {

		LOGGER.log(Level.FINE, StringUtils.EMPTY, pThrowable);
	}

	public void debug(String pMessage, Throwable pThrowable) {

		LOGGER.log(Level.FINE, pMessage, pThrowable);
	}

	public boolean isInfoEnabled() {

		return LOGGER.isLoggable(Level.INFO);
	}

	public void info(String pMessage) {

		LOGGER.log(Level.INFO, pMessage);
	}

	public void info(Throwable pThrowable) {

		LOGGER.log(Level.INFO, StringUtils.EMPTY, pThrowable);
	}

	public void info(String pMessage, Throwable pThrowable) {

		LOGGER.log(Level.INFO, pMessage, pThrowable);
	}

	public boolean isWarnEnabled() {

		return LOGGER.isLoggable(Level.WARNING);
	}

	public void warn(String pMessage) {

		LOGGER.log(Level.WARNING, pMessage);
	}

	public void warn(Throwable pThrowable) {

		LOGGER.log(Level.WARNING, StringUtils.EMPTY, pThrowable);
	}

	public void warn(String pMessage, Throwable pThrowable) {

		LOGGER.log(Level.WARNING, pMessage, pThrowable);
	}

	public boolean isErrorEnabled() {

		return LOGGER.isLoggable(Level.SEVERE);
	}

	public void error(String pMessage) {

		LOGGER.log(Level.SEVERE, pMessage);
	}

	public void error(Throwable pThrowable) {

		LOGGER.log(Level.SEVERE, StringUtils.EMPTY, pThrowable);
	}

	public void error(String pMessage, Throwable pThrowable) {

		LOGGER.log(Level.SEVERE, pMessage, pThrowable);
	}

	// ------------------------------------------------------------------------
	// METHODES STATIC 'PUBLIC'
	// ------------------------------------------------------------------------

	public static Logger getLogger(String pName) {

		return new Logger(pName);
	}

	public static Logger getLogger(Class<?> pClass) {

		return getLogger(pClass.getName());
	}
}
